import 'package:flutter/material.dart';

class StackTestRoute extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => new _StackTestRouteState();
}

class _StackTestRouteState extends State<StackTestRoute> {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      appBar: new AppBar(
        title: new Text('层叠布局Stack和Potisioned'),
      ),
      body: ConstrainedBox(
        //通过ConstrainedBox来确保Stack占满屏幕
        constraints: BoxConstraints.expand(),
        child: Stack(
          alignment: Alignment.center, //指定未定位或部分定位widget的对齐方式
          children: <Widget>[
            Container(
              child: Text(
                'Hello world',
                style: TextStyle(color: Colors.white),
              ),
              color: Colors.red,
            ),
            Positioned(
              left: 18.0,
              child: Text("I am Jack"),
            ),
            Positioned(
              top: 10.0,
              child: Text('your friend'),
            ),
          ],
        ),
      ),
    );
  }
}
